package com.foo.RealtimeDataProvider;

import java.sql.Date;
import java.sql.Timestamp;

import javax.ejb.Stateless;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.foo.DAO.AnalyzedDAO;
import com.foo.DAO.RealtimeDAO;
import com.foo.DataProvider.ProviderInterface;
import com.foo.DataSender.DataSender;
import com.foo.Entity.RealTimeData;

/**
 * Session Bean implementation class RealtimeDataProvider
 */
@Stateless
public class RealtimeDataProvider implements ProviderInterface{ //RealtimeDataProviderRemote, RealtimeDataProviderLocal {
int total =0 ;
String realtimemessage = ""; 
DataSender datasender = new DataSender();

public RealtimeDataProvider() 
{
	System.out.println("Realtime Data Provider created!");
}

@Override
public void getData(String sorttype,String value, Timestamp timestamp, Date fromdate, Date todate)  
{
	System.out.println("Entering server function RealTime Data with parameters " +sorttype + " and " + timestamp);

	System.out.println("Server side: if condition :");
	// Example for using named query

	ApplicationContext context = new ClassPathXmlApplicationContext("/beans.xml");
	RealtimeDAO forumDAO = (RealtimeDAO) context.getBean("realtimeDAO");   		
	realtimemessage=forumDAO.selectForum(sorttype,timestamp);		

System.out.println("The message " +realtimemessage);
datasender.sendMessage("RealTime",realtimemessage);
}
}
